package com.thti.mecool.client.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.thti.mecool.client.activity.R;

public class UserCenterFirstListAdapter extends BaseAdapter {
	private Context mContext;
	private String[] list;
	private int msgNum;
	
	public UserCenterFirstListAdapter(Context mContext, String[] list) {
		super();
		this.mContext = mContext;
		this.list = list;
	}
	
	public UserCenterFirstListAdapter(Context mContext, String[] list,
			int msgNum) {
		super();
		this.mContext = mContext;
		this.list = list;
		this.msgNum = msgNum;
	}


	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub

		View view =((Activity) mContext).getLayoutInflater().inflate(R.layout.mecool_usercenter_first,null);
		TextView showNum;
		TextView textView;
		
		try {
			showNum=(TextView)view.findViewById(R.id.mecool_usercenter_first_imageview);
			view.setTag(position);
			textView=(TextView)view.findViewById(R.id.mecool_usercenter_first_textview);
			if(msgNum!=0&&position==1){
				showNum.setVisibility(View.VISIBLE);
				showNum.setText(String.valueOf(msgNum));
			}
			textView.setText(list[position]);
		} catch (Exception e) { 
			// TODO: handle exception
		}
		return view;
	}
	
	
	class Viewholder{
		TextView textView;
		ImageView imageView;
	}

}
